﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/admincp.Master" AutoEventWireup="true"
    CodeBehind="Search.aspx.cs" Inherits="VINETLIFE.AdminCP.Search" %>

<%@ Register Assembly="DevExpress.Web.ASPxTreeList.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTreeList" TagPrefix="dxwtl" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v9.2" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<%@ Register assembly="DevExpress.Web.ASPxTreeList.v9.2" namespace="DevExpress.Web.ASPxTreeList" tagprefix="dxwtl" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .search-box
        {
            float: left;
            width: 100%;
        }
        .search-product-cate
        {
            float: left;
            width: 180px;
        }
        .search-container
        {
            float: left;
            margin-left: 5px;
            border: 1px dotted #ccc;
            width: 819px;
        }
        .search-row
        {
            float: left;
            width: 800px;
            margin: 5px 0 0 10px;
        }
        .search-row span
        {
            float: left;
            display: block;
            width: 120px;
            line-height: 30px;
            font-size:16px;
            font-weight:bold;
        }
        .search-tag
        {
            width: 300px;
            float: left;
            outline: none;
        }
        .button1
        {
            padding: 2.5px 5px !important;
            margin-left: 5px !important;
            cursor: pointer;
        }
        .search-result
        {
            margin: 5px 5px 10px 5px;
            float: left;
        }
    </style>
    <script type="text/javascript">
        var keyword = $("#txtKeyWord").val().split(' ');
        $.each(keyword, function () {
            $(".a").html(function (index, oldhtml) {
                return oldhtml.replace(keyword, "<span style='background-color:Yellow'>" + keyword + "</span>");
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="search-box">
        <div class="search-product-cate">
            <dxwtl:ASPxTreeList ID="tlCategory" runat="server" AutoGenerateColumns="False" Width="100%"
                ClientInstanceName="tlCategory" KeyFieldName="ProductCategoryID" ParentFieldName="ParentID"
                EnableCallbacks="False">
                  <%-- <SettingsSelection Enabled="True" Recursive="True" />--%>
                <SettingsPager Mode="ShowPager" PageSize="200">
                    <AllButton Text="Tất cả">
                    </AllButton>
                    <NextPageButton Text="Tiếp theo &gt;">
                    </NextPageButton>
                    <PrevPageButton Text="&lt; Trước">
                    </PrevPageButton>
                </SettingsPager>
                <SettingsBehavior AllowFocusedNode="True" />
                <SettingsPager ShowDefaultImages="False">
                    <AllButton Text="Tất cả">
                    </AllButton>
                    <NextPageButton Text="Tiếp theo &gt;">
                    </NextPageButton>
                    <PrevPageButton Text="&lt; Trước">
                    </PrevPageButton>
                </SettingsPager>
                <Columns>
                    <dxwtl:TreeListTextColumn FieldName="ProductCategoryID" Name="clProductCategoryID"
                        Visible="False" VisibleIndex="0">
                    </dxwtl:TreeListTextColumn>
                    <dxwtl:TreeListTextColumn FieldName="ProductCategoryCode" Width="50px" Name="clProductCategoryCode"
                        Caption="Mã danh mục" VisibleIndex="1" Visible="false">
                    </dxwtl:TreeListTextColumn>
                    <dxwtl:TreeListTextColumn Caption="Chọn danh mục sản phẩm" Width="100px" Name="clTenLoaiSanPham"
                        VisibleIndex="2" FieldName="ProductCategoryTitle">
                    </dxwtl:TreeListTextColumn>
                </Columns>
            </dxwtl:ASPxTreeList>
        </div>
        <div class="search-container">
            <div class="search-row">
                <span>Nhập từ khóa:</span><asp:TextBox CssClass="search-tag" runat="server" ID="txtKeyWord"></asp:TextBox>
                <asp:Button runat="server" ID="btnSearch" Text="Tìm kiếm" 
                    CssClass="button-gg-green" onclick="btnSearch_Click" />
            </div>
            <div class="search-result">
            <h2>Danh sách tìm kiếm</h2>
                <asp:GridView ID="grvProduct" DataKeyNames="ProductID" runat="server" AutoGenerateColumns="False"
                    CssClass="tstyle2" PageSize="35" AllowPaging="true" Width="100%" PagerStyle-CssClass="pgr"
                    OnSelectedIndexChanged="grvProduct_SelectedIndexChanged" OnPageIndexChanging="grvProduct_PageIndexChanging"
                    OnRowDeleting="grvProduct_RowDeleting">
                    <Columns>
                        <asp:TemplateField HeaderText="ProductID" Visible="false" ItemStyle-Width="5%">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblProductID" Text='<%#Eval("ProductID") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Mã sản phẩm" ItemStyle-Width="5%">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblProductCode" Text='<%#Eval("ProductCode") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Tên sản phẩm" ItemStyle-Width="10%">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblProductTitle" Text='<%#Eval("ProductTitle") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Danh mục sản phẩm" ItemStyle-Width="10%">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblProductCategoryTitle" CssClass="a" Text='<%#Eval("ProductCategoryTitle") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Thuộc tính" ItemStyle-Width="30%">
                            <ItemTemplate>
                                <asp:Repeater runat="server" ID="rptProductProperties" DataSource='<%#ProductPropertiesDataSource(int.Parse(DataBinder.Eval(Container.DataItem,"ProductID").ToString())) %>'>
                                    <ItemTemplate>
                                        <div class="properties-wrap">
                                            <asp:Label runat="server" ID="lblPropertyName" Text='<%#Eval("PropertyName") %>'></asp:Label>:
                                            <asp:Label runat="server" ID="lblValue" Text='<%#Eval("Value") %>' CssClass="bold"></asp:Label>
                                        </div>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Số thứ tự" ItemStyle-Width="5%">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblOrderID" Text='<%#Eval("OrderID") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField Visible="false" ItemStyle-Width="10%" HeaderText="Thao tác" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" runat="server" CommandName="Select" ImageUrl="~/AdminCP/images/edit_16x16.gif" />
                                <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%#Eval("ProductID") %>'
                                    CommandName="Delete" ImageUrl="~/AdminCP/images/delete_16x16.gif" OnClientClick="return confirm('Có muốn xóa bản ghi này? Nhấn OK để xóa!')" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </div>
        </div>
    </div>
</asp:Content>
